package com.itmei.sms.controller;

import com.itmei.sms.exception.ServiceException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.rowset.serial.SerialException;

/**
 * @Author itmei
 * @Date 2023/2/7 15:34
 * @description: 异常测试控制类
 * @Title: ExcepController
 * @Package com.itmei.sms.controller
 */
@RestController
public class ExcepController {
    /**
     * 计算除数
     */
    @GetMapping("compute/divide")
    public ResponseEntity<String> compute(String divisor, String dividend) {
        if ("0".equals(dividend)){
            throw new ServiceException(1,"分母不能为0");
        }
        Integer value = Integer.valueOf(divisor) / Integer.valueOf(dividend);
        return ResponseEntity.ok("计算后的结果："+value.toString());
    }
}
